from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

from Pages.BasePage import Action


class BrowserEngine(object):
    def __init__(self, driver):
        self.driver = driver
        #期望唤起的浏览器
        self.browser = "CHROME"


    def open_browser(self, driver):
        if self.browser.upper() == "CHROME":
            option = webdriver.ChromeOptions()
            option.add_argument("start-maximized")
            driver = webdriver.Chrome(options=option)
            # driver.maximize_window()
        elif self.browser.upper() == "IE":
            driver = webdriver.Ie()
            driver.maximize_window()
        elif self.browser.upper() == "EDGE":
            driver = webdriver.Edge()
            driver.maximize_window()
        elif self.browser.upper() == "REMOTE":
            pass
            #driver = webdriver.Remote(
            #    command_executor='http://127.0.0.1:4444/wd/hub',
            #    desired_capabilities=DesiredCapabilities.CHROME)
        Action._driver = driver
        return driver